<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script type="text/javascript" src="//api.map.baidu.com/api?type=webgl&v=1.0&ak=oyva8hEbGyySeHenlvpaPYgbblTWU2mA"></script>
    <script src="https://code.bdstatic.com/npm/jquery@1.12.4/dist/jquery.min.js"></script>
    <title>单个逆地址解析</title>
    <style>
        body,html{
           width: 100%;
           height: 100%;
           padding: 0;
           margin: 0;
       }
       #container{
           width: 100%;
           height: 100%;
           overflow: hidden;
       }
       #result{
           position: fixed;
           top: 10px;
           left: 10px;
           padding: 0px 7px;
           min-width: 350px;
           height: 70px;
           line-height: 35px;
           background: #fff;
           box-shadow: 0 2px 6px 0 rgba(27, 142, 236, 0.5);
           border-radius: 7px;
           z-index: 99;
       }
    </style>
</head>
<body>
  <div id='container'></div>
  <div id='result'>
      点击展示详细的地址：
      <div id='result_l'></div>
  </div>
  <script>
    //实例化地图
    var map = new BMapGL.Map('container');
    map.centerAndZoom(new BMapGL.Point(116.331398,39.897445), 15);
    map.enableScrollWheelZoom(true);

    // 创建逆地址解析对象Geocoder
    var geoc = new BMapGL.Geocoder();
    // 给地图绑定点击监听
    map.addEventListener('click', function(e){
      //清除地图上所有的覆盖物
      map.clearOverlays();
      // 得到点击位置的point
      var point = e.latlng;
      // 给点击位置添加覆盖物
      var marker = new BMapGL.Marker(new BMapGL.Point(point.lng, point.lat));
      map.addOverlay(marker);
      // 得到点击point的address名称
      geoc.getLocation(point, function(rs){
        var addComp = rs.addressComponents;
        $('#result_l').text(addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber);
      })
    })
  </script>
</body>
</html>